package edu.bupt.segmenter;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class Chain {

	/**
	 * @param args
	 */
	private BlockingQueue<String> waitedBlockingQueue = new ArrayBlockingQueue<String>(1000);
	private BlockingQueue<String> finishedBlockingQueue = new ArrayBlockingQueue<String>(1000);
	public void process(){
		LoadPapersHandler lpHandler = new LoadPapersHandler(waitedBlockingQueue);
		SegmentHandler sHandler1 = new SegmentHandler(waitedBlockingQueue,finishedBlockingQueue);
		SegmentHandler sHandler2 = new SegmentHandler(waitedBlockingQueue,finishedBlockingQueue);
		SegmentHandler	sHandler3 = new SegmentHandler(waitedBlockingQueue,finishedBlockingQueue);
		WriteHandler wHandler = new WriteHandler(finishedBlockingQueue);
		
		Thread thread1 = new Thread(sHandler1);
		Thread thread2 = new Thread(sHandler2);
		Thread thread3 = new Thread(sHandler3);
		Thread loadThread = new Thread(lpHandler);
		Thread writeThread = new Thread(wHandler);
		
		thread1.start();
		thread2.start();
		thread3.start();
		loadThread.start();
		writeThread.start();
		
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Chain().process();
	}

}
